#include <rasqal.h>
#include <redland.h>
#include <raptor2.h>
#include <rasqal.h>
#define RASQAL_INTERNAL
#include <rasqal_internal.h>
#include <raptor_internal.h>

#include <QtCore>
#include <QCoreApplication>
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <string>
#include <sstream>
#include <QCryptographicHash>
#include "SemanticUtil/NTuple.h"
#include "SemanticUtil/Binding.h"
#include "FwdInfer/Statement.h"


#ifndef _RDFSTORE_H_
#define _RDFSTORE_H_

class RdfStore{
public:
	RdfStore();
	RdfStore(int i);
	RdfStore(std::string option);
	RdfStore(std::string option,std::string db_name);
	~RdfStore();
	int store_triple(const char *s, const char *p, const char *o);
	void exec_query(std::string query);
	void clean_storage();
	int print_query_results(librdf_world* world, librdf_model* model, librdf_query_results *results);
	void librdf_node_print2(librdf_node *node, FILE *fh,std::string &result);
	void librdf_node_print3(librdf_node *node, FILE *fh,QFile &resultFile);
	int librdf_node_write2(librdf_node* node, raptor_iostream *iostr, std::string &result);
	int librdf_node_write3(librdf_node* node, raptor_iostream *iostr, QFile &resultFile);
	std::vector<NTuple> getReault();
	std::string resultString();
	bool containsAnyStatement(Statement);
	void addStatement(Statement);
public:
	librdf_world* world;
	librdf_model* model;
	librdf_node* context_node;
	librdf_node *node;
    /*
     * 初始化与存储相关的资源
     */
    librdf_storage *storage;
    librdf_hash *options;
    int transactions;
    const char* storage_name;
    const char* context;
    std::string node_identifier;
    const char* identifier;
    int counter;
    librdf_query *subquery;
    librdf_query_results *results;
    std::string variable_result[3];
    std::vector<NTuple> partialResult;
    std::string bool_ans;
};
#endif //_RDFSTORE_H_
